package org.bedracket.pgeg.init;

import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.bedracket.pgeg.PGEGMod;
import org.bedracket.pgeg.enchantment.*;

import java.util.function.Supplier;

public class ModEnchantments {

    public static final DeferredRegister<Enchantment> ENCHANTMENTS =
            DeferredRegister.create(ForgeRegistries.ENCHANTMENTS,
                    PGEGMod.MOD_ID);

    public static final RegistryObject<Enchantment> VAMPIRISM = register("vamprisim",
            VampirismEnchantment::new);

    public static final RegistryObject<Enchantment> RANDOMIZATION = register("randomization",
            RandomizationEnchantment::new);

    public static final RegistryObject<Enchantment> POISONOUS = register("poisonous",
            PoisonousEnchantment::new);

    public static final RegistryObject<Enchantment> EXPANSION = register("expansion",
            ExpansionEnchantment::new);

    public static final RegistryObject<Enchantment> CURSE_PAIN = register("curse_pain",
            CursePainEnchantment::new);

    public static final RegistryObject<Enchantment> BEHEADING = register("beheading",
            BeheadingEnchantment::new);

    /**
     * Used for registry enchantments
     *
     * @param name Items' registry name
     * @param enchantmentSupplier enchantmentSupplier
     * @param <T>  sth extends Enchantment
     * @return new RegistryObject<Enchantment>
     */
    private static <T extends Enchantment> RegistryObject<T> register(String name, Supplier<T> enchantmentSupplier) {
        return ENCHANTMENTS.register(name, enchantmentSupplier);
    }

}
